<?php
//CubeUserSystem 插件信息
//
//名称：获取与校验信息模块
//作者：方块盒子工作室
//插件版本：v1.0
//此插件属于官方插件，请放心使用，如果害怕被篡改，请检查代码或重新下载

//主要部分
//调用数据库
$setting = json_decode(file_get_contents("setting/main.json"),true);
$tokendata = json_decode(file_get_contents("userdata/token.json"),true);
//开始
if(isset($_GET['method'])){
	if($_GET['method'] == "check"){
		if(isset($_GET['username'],$_GET['token'])){
			if(isset($tokendata[$_GET['username']])){
				if($_GET['token'] == $tokendata[$_GET['username']]){
					$success = true;
					$putout = array(
						"success" => $success,
						"username" => $_GET['username'],
						"token" => $_GET['token'],
					);
					echo json_encode($putout);
				}else{
					$success = false;
					$putout = array(
						"success" => $success,
						"msg" => "用户名与密钥不匹配",
					);
					echo json_encode($putout);
				}
			}else{
				$success = false;
				$putout = array(
					"success" => $success,
					"msg" => "不存在账户",
				);
				echo json_encode($putout);
			}
		}else{
			$success = false;
			$putout = array(
				"success" => $success,
				"msg" => "没有用户名或密码",
			);
			echo json_encode($putout);
		}
	}
}else{
	$success = false;
	$putout = array(
		"success" => $success,
		"msg" => "没有检查项",
	);
	echo json_encode($putout);
}
?>